unit pilaBool;

interface
  Type
    TelemBool = boolean;
    TpilaBool = ^Nodo;
    Nodo = record
      elem: TelemBool;
      sig: TpilaBool;
  end;
    procedure crearPilaBool (var pila: TpilaBool);
    function pilaBoolVacia (pila: TpilaBool): boolean;
    procedure apilarBool (var pila: TpilaBool; elem: TelemBool);
    procedure desapilarBool (var pila: TpilaBool);
    function cimaBool (pila: TpilaBool): TelemBool;
    procedure destruirPilaBool(pila: TpilaBool);

implementation

procedure crearPilaBool (var pila: TpilaBool);
begin
  pila := nil;
end;

procedure destruirPilaBool(pila: TpilaBool);
begin
  dispose (pila);
end;


function pilaBoolVacia (pila: TpilaBool): boolean;
begin
  pilaBoolVacia:= pila = nil;
end;

procedure apilarBool (var pila: TpilaBool; elem: TelemBool);
var
  aux: TpilaBool;
begin
  new (aux);
  aux^.elem := elem;
  aux^.sig := pila;
  pila := aux;
end;

procedure desapilarBool (var pila: TpilaBool);
var
  aux: TpilaBool;
begin
  if not pilaBoolVacia(pila) then
  begin
    aux := pila;
    pila := pila^.sig;
    dispose (aux);
  end;
end;

function cimaBool (pila: TpilaBool): TelemBool;
begin
  if not pilaBoolVacia (pila) then
    result := pila^.elem;
end;

end.
 